export default {
  data() {
    let handlerPhone = (rule, value, callback) => {
      if (!this.regCheck('empty', value)) {
        callback(new Error('请输入联系电话'))
      } else if (this.regCheck('phone', value)) {
        callback(new Error('请输入正确的联系电话'))
      } else {
        callback()
      }
    }
    let handlerCertificatesNumber = (rule, value, callback) => {
      if (!this.regCheck('empty', value)) {
        callback(new Error('请输入证件号码'))
      } else {
        callback()
      }
    }
    let handlerMailbox = (rule, value, callback) => {
      if (!this.regCheck('empty', value)) {
        callback(new Error('请输入经办人电子邮箱'))
      } else if (this.regCheck('email', value)) {
        callback(new Error('请输入正确的经办人电子邮箱'))
      } else {
        callback()
      }
    }
    return {
      ruleForm: {
        companyName: '', //单位名称（中英文对照）
        handlerName: '', //经办人姓名
        handlerPhone: '', //经办人联系电话
        handlerMailbox: '', //经办人电子邮箱
        handlerCertificatesType: '', //经办人证件类型
        handlerSex: '', //经办人性别
        handlerCertificatesNumber: '', //经办人证件号码
        companyCertificateFile: '', //上传单位开业证书信息页
        handlerCertificateFile: '', //上传经办人证件信息页
      },
      rules: {
        companyName: [
          { required: true, message: '请输入单位名称（中英文对照）', trigger: 'blur' },
        ],
        handlerName: [
          { required: true, message: '请输入经办人姓名', trigger: 'blur' },
        ],
        handlerPhone: [
          { required: true, validator: handlerPhone, trigger: 'blur' },
        ],
        handlerMailbox: [
          { required: true, validator: handlerMailbox, trigger: 'blur' },
        ],
        handlerSex: [
          { required: true, message: '请选择经办人性别', trigger: 'change' },
        ],
        handlerCertificatesNumber: [
          { required: true, validator: handlerCertificatesNumber, trigger: 'blur' },
        ],
        handlerCertificatesType: [
          { required: true, message: '请选择经办人证件类型', trigger: 'change' },
        ],
        companyCertificateFile: [
          { required: true, message: '请选择上传单位开业证书信息页', trigger: 'change' },
        ],
        handlerCertificateFile: [
          { required: true, message: '请选择上传经办人证件信息页', trigger: 'change' }
        ]
      },
    }
  }
}
